﻿using System;
using System.Windows.Forms;

namespace Rename
{
    internal static class Ext
    {
        public static void SetTextAsync(this Label label,string txt)
        {
            try
            {
                if (label.InvokeRequired)
                {
                    var InvokeCallback = new Action<Label, string>(SetTextAsync);
                    if (label.IsDisposed == true)
                        return;
                    label.Invoke(InvokeCallback, label, txt);
                }
                else
                {
                    if (label.IsDisposed)
                        return;
                    label.Text = txt;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + ex.StackTrace);
            }
        } 

    }
}
